package com.sbm.datasource.dynamic;

import java.util.ArrayList;
import java.util.List;

public class DynamicDataSourceHolder {
    private static ThreadLocal<String> currentDataSource = new ThreadLocal<String>();

    private static List<String> dataSources = new ArrayList<String>();

    public static String getCurrentDataSources() {
        return currentDataSource.get();
    }

    public static void setCurrentDataSource(String dataSource) {
        currentDataSource.set(dataSource);
    }

    public static void clearCurrentDataSource() {
        currentDataSource.remove();
    }

    public static boolean containsDataSource(String dataSource) {
        return dataSources.contains(dataSource);
    }

    public static void addDataSource(String dataSource) {
        if (!dataSources.contains(dataSource))
            dataSources.add(dataSource);
    }
}
